package com.reserv.servlet;

import java.io.IOException;

import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.reserv.dao.ReservDAO;
import com.reserv.util.TimestampUtil;
import com.reserv.vo.ReservVO;


public class MakeReservServlet extends HttpServlet {
	private ReservDAO dao;
	@Override
	public void init(ServletConfig config) throws ServletException {
		dao = ReservDAO.getInstance();

	}
	private void doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//sno: sno, uid: uid, pt: pt, ppl: ppl, fee: fee, rvDate: rvDate
		int sno = Integer.parseInt(request.getParameter("sno"));
		String uid = request.getParameter("uid");
		int pt = Integer.parseInt(request.getParameter("pt"));
		int ppl = Integer.parseInt(request.getParameter("ppl"));
		int fee = Integer.parseInt(request.getParameter("fee"));
		String rvDate = request.getParameter("rvDate");
		
		TimestampUtil tsu = new TimestampUtil();
		
		ReservVO r = new ReservVO();
		r.setSno(sno);
		r.setUid(uid);
		r.setPt(pt);
		r.setPpl(ppl);
		r.setFee(fee);
		r.setRvDate(tsu.toTimestamp(rvDate));
		dao.createVO(r);
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request, response);
	}
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doProcess(request, response);
	}
}